/*
 * @Author: funlee
 * @Email: i@funlee.cn
 * @Date: 2019-06-21 11:28:36
 * @Description: 首页-应用工具-已暴雷名单
 */
import { observable, action } from "mobx";
import resource from "@/utils/resource";
import API from "@/utils/api";

class GoBustListsStore {
    @observable keyWords = "";
    @observable sourceType = "all";
    @observable listsData = "";
    @observable currentPage = 1;

    @action.bound
    setNature(type, value) {
        this[type] = value;
    }

    @action.bound
    changePage(newPage) {
        this.currentPage = newPage;
        this.getData();
    }

    @action.bound
    getData() {
        // const { keyWords } = this;
        // if (keyWords === "") {
        //     message.error("请输入关键字");
        //     return;
        // }

        resource
            .get(API.homeGoBustListsSearch, {
                keyWords: this.keyWords,
                sourceType: this.sourceType
            })
            .then(res => {
                this.listsData = res;
            });
    }
}

export default new GoBustListsStore();
